<!-- 协议 -->
<template>
  <div class="">
    <Ueditor v-model="userAgreement" editorId="agreement" />
    <a-button v-has="'system:baseConfig:agreement:edit'" type="primary" size="large" style="margin-top: 20px" @click="handleSave">保存</a-button>
  </div>
</template>

<script>
import Ueditor from '@/components/Ueditor'
import { configApp, saveConfigApp } from '@/api/web/web'
export default {
  components: {
    Ueditor
  },
  props: ['type'],
  data() {
    return {
      userAgreement: undefined
    }
  },
  computed: {},
  methods: {
    async getConfigApp() {
      let res = await configApp()
      this.userAgreement = res.data[this.type]
    },
    async handleSave() {
      let { msg } = await saveConfigApp({ [this.type]: this.userAgreement })
      this.$message.success(msg)
    }
  },
  created() {
    this.getConfigApp()
  },
  watch: {
    type(nval,oval){
      this.getConfigApp()
    }
  },
  mounted() {}
}
</script>
<style scoped></style>
